/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.rantipin.persistence;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author rantipin
 */
@Entity
@Table(name = "research")
@NamedQueries({@NamedQuery(name = "Research.findAll", query = "SELECT r FROM Research r"), @NamedQuery(name = "Research.findById", query = "SELECT r FROM Research r WHERE r.id = :id"), @NamedQuery(name = "Research.findByName", query = "SELECT r FROM Research r WHERE r.name = :name"), @NamedQuery(name = "Research.findByDate", query = "SELECT r FROM Research r WHERE r.date = :date"), @NamedQuery(name = "Research.findByDescription", query = "SELECT r FROM Research r WHERE r.description = :description"), @NamedQuery(name = "Research.findByIdx", query = "SELECT r FROM Research r WHERE r.idx = :idx"), @NamedQuery(name = "Research.findByComment", query = "SELECT r FROM Research r WHERE r.comment = :comment")})
public class Research implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "name")
    private String name;
    @Column(name = "date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @Column(name = "description")
    private String description;
    @Column(name = "idx")
    private String idx;
    @Column(name = "comment")
    private String comment;
    @OneToMany(mappedBy = "idResearch", fetch = FetchType.LAZY)
    private Collection<Production> productionCollection;

    public Research() {
    }

    public Research(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getIdx() {
        return idx;
    }

    public void setIdx(String idx) {
        this.idx = idx;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Collection<Production> getProductionCollection() {
        return productionCollection;
    }

    public void setProductionCollection(Collection<Production> productionCollection) {
        this.productionCollection = productionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Research)) {
            return false;
        }
        Research other = (Research) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ru.rantipin.persistence.Research[id=" + id + "]";
    }

}
